<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>健康卡片</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
            background: #f5f5f5;
            padding: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
        }

        .card-container {
            width: 340px;
            background: white;
            border-radius: 28px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }

        .top-gradient {
            background: linear-gradient(180deg, #3d8944 0%, #4caf50 100%);
            padding: 24px 20px 32px;
            position: relative;
        }

        .user-info-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 20px;
        }

        .user-avatar-wrapper {
            position: relative;
            margin-right: 16px;
        }

        .user-avatar {
            width: 110px;
            height: 110px;
            border-radius: 50%;
            background: white;
            border: 5px solid white;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
            object-fit: cover;
        }

        .crown-badge {
            position: absolute;
            right: -2px;
            top: -2px;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            border: 3px solid white;
        }

        .user-details {
            flex: 1;
        }

        .name-row {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 10px;
        }

        .user-name {
            font-size: 38px;
            color: white;
            font-weight: bold;
        }

        .health-code-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 64px;
            height: 64px;
            background: rgba(255, 255, 255, 0.25);
            border-radius: 50%;
            cursor: pointer;
            transition: opacity 0.3s;
        }

        .health-code-btn:active {
            opacity: 0.8;
        }

        .health-code-icon {
            width: 42px;
            height: 42px;
        }

        .stats-row {
            display: flex;
            align-items: baseline;
            gap: 20px;
        }

        .stat-item {
            display: flex;
            align-items: baseline;
            gap: 6px;
        }

        .stat-label {
            font-size: 24px;
            color: rgba(255, 255, 255, 0.85);
        }

        .stat-value {
            font-size: 36px;
            color: white;
            font-weight: bold;
        }

        .divider {
            width: 2px;
            height: 28px;
            background: rgba(255, 255, 255, 0.3);
        }

        .guardian-switch {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 14px;
            padding: 14px;
            cursor: pointer;
            transition: opacity 0.3s;
        }

        .guardian-switch:active {
            opacity: 0.8;
        }

        .guardian-info {
            display: flex;
            align-items: center;
            flex: 1;
            min-width: 0;
        }

        .guardian-label {
            font-size: 26px;
            color: white;
            font-weight: 500;
            margin-right: 8px;
        }

        .guardian-name {
            font-size: 24px;
            color: rgba(255, 255, 255, 0.9);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            flex: 1;
        }

        .guardian-action {
            font-size: 26px;
            color: white;
            font-weight: bold;
            margin-left: 12px;
        }

        .account-cards {
            padding: 0 20px;
            margin-top: -20px;
            margin-bottom: 20px;
        }

        .account-cards-row {
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .account-card {
            flex: 1;
            background: white;
            border-radius: 20px;
            padding: 20px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            border: 1px solid #e5e5e5;
        }

        .account-label {
            font-size: 24px;
            color: #666;
            display: block;
            margin-bottom: 10px;
        }

        .account-value-row {
            display: flex;
            align-items: baseline;
        }

        .account-value {
            font-size: 44px;
            color: #3d8944;
            font-weight: bold;
        }

        .account-unit {
            font-size: 26px;
            color: #999;
            margin-left: 8px;
        }

        .main-functions {
            padding: 0 20px;
            margin-bottom: 20px;
        }

        .health-record-card {
            border-radius: 20px;
            overflow: hidden;
            margin-bottom: 16px;
            cursor: pointer;
            transition: opacity 0.3s;
            background: linear-gradient(135deg, #3d8944 0%, #4caf50 100%);
        }

        .health-record-card:active {
            opacity: 0.8;
        }

        .health-record-content {
            padding: 24px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .health-record-left {
            display: flex;
            align-items: center;
            flex: 1;
        }

        .health-record-icon-wrapper {
            width: 72px;
            height: 72px;
            background: rgba(255, 255, 255, 0.25);
            border-radius: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 16px;
        }

        .health-record-icon {
            width: 44px;
            height: 44px;
        }

        .health-record-text {
            color: white;
        }

        .health-record-title {
            font-size: 32px;
            color: white;
            font-weight: bold;
            display: block;
            margin-bottom: 6px;
        }

        .health-record-desc {
            font-size: 22px;
            color: rgba(255, 255, 255, 0.85);
        }

        .health-record-arrow {
            color: white;
            font-size: 40px;
            font-weight: 300;
        }

        .health-manager-card {
            background: #f5f5f5;
            border-radius: 20px;
            padding: 18px;
            margin-bottom: 16px;
            cursor: pointer;
            transition: opacity 0.3s;
        }

        .health-manager-card:active {
            opacity: 0.8;
        }

        .health-manager-content {
            display: flex;
            align-items: center;
        }

        .health-manager-icon-wrapper {
            width: 64px;
            height: 64px;
            border-radius: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 16px;
            background: linear-gradient(135deg, #3d8944 0%, #4caf50 100%);
        }

        .health-manager-icon {
            width: 32px;
            height: 32px;
            color: white;
        }

        .health-manager-info {
            flex: 1;
        }

        .health-manager-name {
            font-size: 30px;
            color: #333;
            font-weight: 500;
            display: block;
            margin-bottom: 4px;
        }

        .health-manager-label {
            font-size: 22px;
            color: #999;
        }

        .health-manager-arrow {
            color: #ccc;
            font-size: 36px;
            font-weight: 300;
        }

        .bottom-functions {
            padding: 0 20px 24px;
        }

        .bottom-functions-row {
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .bottom-function-card {
            flex: 1;
            background: #f5f5f5;
            border-radius: 18px;
            padding: 18px;
            cursor: pointer;
            transition: opacity 0.3s;
        }

        .bottom-function-card:active {
            opacity: 0.8;
        }

        .bottom-function-icon-wrapper {
            width: 60px;
            height: 60px;
            background: white;
            border-radius: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            margin: 0 auto 10px;
        }

        .bottom-function-icon {
            width: 42px;
            height: 42px;
        }

        .bottom-function-text {
            font-size: 26px;
            color: #666;
            font-weight: 500;
            text-align: center;
            display: block;
        }
    </style>
</head>
<body>
    <div class="card-container" id="cardContainer"></div>

    <script>
        // 页面数据结构 JSON
        const cardData = {
            "container": {
                "type": "view",
                "class": "card-container",
                "children": [
                    {
                        "type": "topSection",
                        "class": "top-gradient",
                        "data": {
                            "user": {
                                "avatar": "https://via.placeholder.com/110",
                                "name": "张三",
                                "crownBadge": "https://via.placeholder.com/40"
                            },
                            "healthCode": {
                                "icon": "https://via.placeholder.com/42",
                                "clickable": true
                            },
                            "stats": {
                                "points": {
                                    "label": "积分",
                                    "value": "0"
                                },
                                "balance": {
                                    "label": "余额",
                                    "value": "0"
                                }
                            },
                            "guardian": {
                                "label": "被监护人",
                                "name": "李四",
                                "action": "切换"
                            }
                        }
                    },
                    {
                        "type": "accountCards",
                        "class": "account-cards",
                        "data": {
                            "cards": [
                                {
                                    "label": "兑换券",
                                    "value": "0",
                                    "unit": "张"
                                },
                                {
                                    "label": "账户余额",
                                    "value": "0",
                                    "unit": "元"
                                }
                            ]
                        }
                    },
                    {
                        "type": "mainFunctions",
                        "class": "main-functions",
                        "data": {
                            "healthRecord": {
                                "title": "健康档案",
                                "description": "查看完整健康记录",
                                "icon": "https://via.placeholder.com/44",
                                "clickable": true
                            },
                            "healthManager": {
                                "name": "管家",
                                "label": "健康管家",
                                "icon": "👤",
                                "clickable": true
                            }
                        }
                    },
                    {
                        "type": "bottomFunctions",
                        "class": "bottom-functions",
                        "data": {
                            "functions": [
                                {
                                    "icon": "https://via.placeholder.com/42",
                                    "text": "专属服务群",
                                    "clickable": true
                                },
                                {
                                    "icon": "https://via.placeholder.com/42",
                                    "text": "历史记录",
                                    "clickable": true
                                }
                            ]
                        }
                    }
                ]
            }
        };

        // 渲染函数
        function renderCard() {
            const container = document.getElementById('cardContainer');
            const data = cardData.container;
            
            // 渲染顶部区域
            const topSection = document.createElement('div');
            topSection.className = 'top-gradient';
            
            // 用户信息行
            const userInfoRow = document.createElement('div');
            userInfoRow.className = 'user-info-row';
            
            const userAvatarWrapper = document.createElement('div');
            userAvatarWrapper.className = 'user-avatar-wrapper';
            
            const avatar = document.createElement('img');
            avatar.className = 'user-avatar';
            avatar.src = data.children[0].data.user.avatar;
            avatar.alt = '用户头像';
            
            const crownBadge = document.createElement('img');
            crownBadge.className = 'crown-badge';
            crownBadge.src = data.children[0].data.user.crownBadge;
            crownBadge.alt = '皇冠';
            
            userAvatarWrapper.appendChild(avatar);
            userAvatarWrapper.appendChild(crownBadge);
            
            const userDetails = document.createElement('div');
            userDetails.className = 'user-details';
            
            const nameRow = document.createElement('div');
            nameRow.className = 'name-row';
            
            const userName = document.createElement('span');
            userName.className = 'user-name';
            userName.textContent = data.children[0].data.user.name;
            
            const healthCodeBtn = document.createElement('div');
            healthCodeBtn.className = 'health-code-btn';
            const healthCodeIcon = document.createElement('img');
            healthCodeIcon.className = 'health-code-icon';
            healthCodeIcon.src = data.children[0].data.healthCode.icon;
            healthCodeIcon.alt = '健康码';
            healthCodeBtn.appendChild(healthCodeIcon);
            
            nameRow.appendChild(userName);
            nameRow.appendChild(healthCodeBtn);
            
            const statsRow = document.createElement('div');
            statsRow.className = 'stats-row';
            
            const pointsItem = document.createElement('div');
            pointsItem.className = 'stat-item';
            const pointsLabel = document.createElement('span');
            pointsLabel.className = 'stat-label';
            pointsLabel.textContent = data.children[0].data.stats.points.label;
            const pointsValue = document.createElement('span');
            pointsValue.className = 'stat-value';
            pointsValue.textContent = data.children[0].data.stats.points.value;
            pointsItem.appendChild(pointsLabel);
            pointsItem.appendChild(pointsValue);
            
            const divider = document.createElement('div');
            divider.className = 'divider';
            
            const balanceItem = document.createElement('div');
            balanceItem.className = 'stat-item';
            const balanceLabel = document.createElement('span');
            balanceLabel.className = 'stat-label';
            balanceLabel.textContent = data.children[0].data.stats.balance.label;
            const balanceValue = document.createElement('span');
            balanceValue.className = 'stat-value';
            balanceValue.textContent = data.children[0].data.stats.balance.value;
            balanceItem.appendChild(balanceLabel);
            balanceItem.appendChild(balanceValue);
            
            statsRow.appendChild(pointsItem);
            statsRow.appendChild(divider);
            statsRow.appendChild(balanceItem);
            
            userDetails.appendChild(nameRow);
            userDetails.appendChild(statsRow);
            
            userInfoRow.appendChild(userAvatarWrapper);
            userInfoRow.appendChild(userDetails);
            
            // 被监护人切换
            const guardianSwitch = document.createElement('div');
            guardianSwitch.className = 'guardian-switch';
            const guardianInfo = document.createElement('div');
            guardianInfo.className = 'guardian-info';
            const guardianLabel = document.createElement('span');
            guardianLabel.className = 'guardian-label';
            guardianLabel.textContent = data.children[0].data.guardian.label;
            const guardianName = document.createElement('span');
            guardianName.className = 'guardian-name';
            guardianName.textContent = data.children[0].data.guardian.name;
            const guardianAction = document.createElement('span');
            guardianAction.className = 'guardian-action';
            guardianAction.textContent = data.children[0].data.guardian.action + ' ›';
            
            guardianInfo.appendChild(guardianLabel);
            guardianInfo.appendChild(guardianName);
            guardianSwitch.appendChild(guardianInfo);
            guardianSwitch.appendChild(guardianAction);
            
            topSection.appendChild(userInfoRow);
            topSection.appendChild(guardianSwitch);
            
            // 账户信息卡片
            const accountCards = document.createElement('div');
            accountCards.className = 'account-cards';
            const accountCardsRow = document.createElement('div');
            accountCardsRow.className = 'account-cards-row';
            
            data.children[1].data.cards.forEach(card => {
                const accountCard = document.createElement('div');
                accountCard.className = 'account-card';
                
                const label = document.createElement('span');
                label.className = 'account-label';
                label.textContent = card.label;
                
                const valueRow = document.createElement('div');
                valueRow.className = 'account-value-row';
                
                const value = document.createElement('span');
                value.className = 'account-value';
                value.textContent = card.value;
                
                const unit = document.createElement('span');
                unit.className = 'account-unit';
                unit.textContent = card.unit;
                
                valueRow.appendChild(value);
                valueRow.appendChild(unit);
                
                accountCard.appendChild(label);
                accountCard.appendChild(valueRow);
                accountCardsRow.appendChild(accountCard);
            });
            
            accountCards.appendChild(accountCardsRow);
            
            // 主要功能区域
            const mainFunctions = document.createElement('div');
            mainFunctions.className = 'main-functions';
            
            // 健康档案
            const healthRecordCard = document.createElement('div');
            healthRecordCard.className = 'health-record-card';
            const healthRecordContent = document.createElement('div');
            healthRecordContent.className = 'health-record-content';
            
            const healthRecordLeft = document.createElement('div');
            healthRecordLeft.className = 'health-record-left';
            
            const healthRecordIconWrapper = document.createElement('div');
            healthRecordIconWrapper.className = 'health-record-icon-wrapper';
            const healthRecordIcon = document.createElement('img');
            healthRecordIcon.className = 'health-record-icon';
            healthRecordIcon.src = data.children[2].data.healthRecord.icon;
            healthRecordIcon.alt = '健康档案';
            healthRecordIconWrapper.appendChild(healthRecordIcon);
            
            const healthRecordText = document.createElement('div');
            healthRecordText.className = 'health-record-text';
            const healthRecordTitle = document.createElement('span');
            healthRecordTitle.className = 'health-record-title';
            healthRecordTitle.textContent = data.children[2].data.healthRecord.title;
            const healthRecordDesc = document.createElement('span');
            healthRecordDesc.className = 'health-record-desc';
            healthRecordDesc.textContent = data.children[2].data.healthRecord.description;
            
            healthRecordText.appendChild(healthRecordTitle);
            healthRecordText.appendChild(healthRecordDesc);
            
            healthRecordLeft.appendChild(healthRecordIconWrapper);
            healthRecordLeft.appendChild(healthRecordText);
            
            const healthRecordArrow = document.createElement('span');
            healthRecordArrow.className = 'health-record-arrow';
            healthRecordArrow.textContent = '›';
            
            healthRecordContent.appendChild(healthRecordLeft);
            healthRecordContent.appendChild(healthRecordArrow);
            healthRecordCard.appendChild(healthRecordContent);
            
            // 健康管家
            const healthManagerCard = document.createElement('div');
            healthManagerCard.className = 'health-manager-card';
            const healthManagerContent = document.createElement('div');
            healthManagerContent.className = 'health-manager-content';
            
            const healthManagerIconWrapper = document.createElement('div');
            healthManagerIconWrapper.className = 'health-manager-icon-wrapper';
            const healthManagerIcon = document.createElement('span');
            healthManagerIcon.className = 'health-manager-icon';
            healthManagerIcon.textContent = data.children[2].data.healthManager.icon;
            healthManagerIconWrapper.appendChild(healthManagerIcon);
            
            const healthManagerInfo = document.createElement('div');
            healthManagerInfo.className = 'health-manager-info';
            const healthManagerName = document.createElement('span');
            healthManagerName.className = 'health-manager-name';
            healthManagerName.textContent = data.children[2].data.healthManager.name;
            const healthManagerLabel = document.createElement('span');
            healthManagerLabel.className = 'health-manager-label';
            healthManagerLabel.textContent = data.children[2].data.healthManager.label;
            
            healthManagerInfo.appendChild(healthManagerName);
            healthManagerInfo.appendChild(healthManagerLabel);
            
            const healthManagerArrow = document.createElement('span');
            healthManagerArrow.className = 'health-manager-arrow';
            healthManagerArrow.textContent = '›';
            
            healthManagerContent.appendChild(healthManagerIconWrapper);
            healthManagerContent.appendChild(healthManagerInfo);
            healthManagerContent.appendChild(healthManagerArrow);
            healthManagerCard.appendChild(healthManagerContent);
            
            mainFunctions.appendChild(healthRecordCard);
            mainFunctions.appendChild(healthManagerCard);
            
            // 底部功能
            const bottomFunctions = document.createElement('div');
            bottomFunctions.className = 'bottom-functions';
            const bottomFunctionsRow = document.createElement('div');
            bottomFunctionsRow.className = 'bottom-functions-row';
            
            data.children[3].data.functions.forEach(func => {
                const bottomFunctionCard = document.createElement('div');
                bottomFunctionCard.className = 'bottom-function-card';
                
                const iconWrapper = document.createElement('div');
                iconWrapper.className = 'bottom-function-icon-wrapper';
                const icon = document.createElement('img');
                icon.className = 'bottom-function-icon';
                icon.src = func.icon;
                icon.alt = func.text;
                iconWrapper.appendChild(icon);
                
                const text = document.createElement('span');
                text.className = 'bottom-function-text';
                text.textContent = func.text;
                
                bottomFunctionCard.appendChild(iconWrapper);
                bottomFunctionCard.appendChild(text);
                bottomFunctionsRow.appendChild(bottomFunctionCard);
            });
            
            bottomFunctions.appendChild(bottomFunctionsRow);
            
            // 组装所有元素
            container.appendChild(topSection);
            container.appendChild(accountCards);
            container.appendChild(mainFunctions);
            container.appendChild(bottomFunctions);
        }

        // 页面加载时渲染
        window.addEventListener('DOMContentLoaded', renderCard);

        // 导出 JSON 数据供外部使用
        console.log('Card Data JSON:', JSON.stringify(cardData, null, 2));
    </script>
</body>
</html>

